var database = require('../../data/data.js')
Page({

  data: {
    team: true,
    flag1: true
  },

  onLoad: function (options) {
    var that = this;
    var login = database.login
    if (!login) {
      this.setData({
        flag1: false
      })
    }
    wx.request({
      url: database.url1 + '/api/V2/softball/softball_list',
      data: {
        accessToken: database.accessToken,
        userId: database.userId
      },
      method: "POST",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success(res) {
        var teamData = res.data;
        if (teamData.data.softballList != null) {
          that.setData({
            team: true
          })
        } else {
          that.setData({
            team: false
          })
        }
      }
    })
  },
  add: function () {
    wx.redirectTo({
      url: '/pages/fight/add/add',
    })
  },
  home: function () {
    wx.navigateBack({
    })
  },
  toBinding: function () {
    this.setData({
      flag1: true
    })
    wx.redirectTo({
      url: '/pages/newBinding/newBinding',
    })
  },
  createTeam: function () {
    this.setData({
      team: true
    })
    wx.redirectTo({
      url: '/pages/my/myteam/createteam/createteam',
    })
  }
})